package com.atwulidun.yygh.msm.receiver;

import com.atwulidun.yygh.msm.service.MsmService;
import com.atwulidun.yygh.rabbit.constant.MqConst;
import com.atwulidun.yygh.vo.msm.MsmVo;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MsmReceiver {
    @Autowired
    private MsmService smsService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = MqConst.QUEUE_MSM_ITEM, durable = "true"),
            exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_MSM),
            key = {MqConst.ROUTING_MSM_ITEM}
    ))
    public void send(MsmVo msmVo, Message message, Channel channel) {
        System.out.println("这边也过来了~~~");
        // 监听到队列有消息，则将消息发送出去
        System.out.println("msmvo=" + msmVo);// msmvo=MsmVo(phone=11111111111, templateCode=null, param={amount=100, name=小张三, quitTime=2021-05-20 15:30, title=北京协和医院|多发性硬化专科门诊|医师, reserveDate=2021-05-21上午})
        // 调用发送msmVo有问题，因为当前容联云只有发送code的功能
//        smsService.send(msmVo);
    }
}
